// Capitalist City - Business Simulation Game
// Copyright (C) 2011 Azlan Mukhtar
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef PRODUCT_SIMULATION_H
#define PRODUCT_SIMULATION_H

#include "product.h"
#include "item.h"
#include "citysimulation.h"

//!  Product Simulation Class.
/*!
 *   This class will handle Products simulation.
 */

class ProductSimulation
{
    friend class Game;
public:
    ProductSimulation();

    //! Constructor - productId counter
    /*! 
     *  Initiate productId counter from the last saved game
     */
    ProductSimulation(quint32 a_productIdCounter);

    //! Destructor
    /*! 
     *  Delete all objects
     */
    ~ProductSimulation();

    //!
    /*!
     *  
     */
    void CalculateSales(City* a_city);


    /*!
     *  
     */
    void AddProduct( quint16 productType = 0,
                        quint8  quality = 0,
                        quint8  brandLoyalty = 0,
                        quint8  brandAwareness = 0,
                        quint64 sellPrice = 0,
                        quint8  rating = 0,
                        quint8  cityAverageRating = 0,
                        quint64 purchasePrice = 0,
                        quint64 freightCost = 0,
                        quint64 totalCost = 0,
                        quint8  marketShare = 0,
                        quint8  productDemand = 0,
                        quint32 productId= 0);

    /*!
     *  
     */
    bool DeleteProduct(quint32 a_productId);

    /*!
     *  
     */
    qint8  CalculateProductRating(Product* product);

    /*!
     *  
     */
    quint8  CalculateCityAverageRating();

    /*!
     *  
     */
    bool   ParseItemsFromFile();

    QMultiMap<quint16, Product*> GetProductMap() { return m_productMap; }
    QList<Item> GetItemList () { return m_itemList; }
    
    bool   isItemDatabaseLoaded;

private:
    Product* m_product;
    QList<Item> m_itemList;
    QList<quint16> m_productTypeList;
    QMultiMap<quint16, Product*> m_productMap;
    quint32 m_productIdCounter;
    City* m_city;

};

#endif // PRODUCT_SIMULATION_H
